﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;

namespace CSharpProj.MyExpression
{
    /// <summary>
    /// Linq集成查询的数据提供器
    /// </summary>
    public abstract class QueryProvider : IQueryProvider
    {
        public QueryProvider( )
        {
        }
        /// <summary>
        /// 根据表达式创建一个可查询对象
        /// </summary>
        public IQueryable CreateQuery(Expression expression)
        {
            return (IQueryable)this.Execute(expression);
        }

        /// <summary>
        /// 根据表达式创建一个可查询对象
        /// </summary>
        public IQueryable<TElement> CreateQuery<TElement>(Expression expression)
        {
        }

        /// <summary>
        /// 根据表达式执行并返回一个结果对象
        /// </summary>
        object IQueryProvider.Execute(Expression expression) { return this.Execute(expression); }

        /// <summary>
        /// 根据表达式执行并返回一个结果对象
        /// </summary>
        TResult IQueryProvider.Execute<TResult>(Expression expression) { return (TResult)this.Execute(expression); }

        /// <summary>
        /// 执行表达式并返回结果
        /// </summary>
        public abstract object Execute(Expression expression);

        /// <summary>
        /// 翻译表达式为查询语句
        /// </summary>
        public abstract string Translate(Expression expression);
    }
}
